<template>
  <table class="table" border="0">
    <thead>
      <tr class="title">
        <th>类型</th>
        <th>名称</th>
        <th>编号</th>
        <th>区域</th>
        <th>状态</th>
        <th>定位</th>
      </tr>
    </thead>
    <tbody>
      <tr v-for="item in datasource">
        <td>
          <div class="status"><Icon name="monitor" :size="28" class="status-icon"></Icon></div>
        </td>

        <td>{{ item.name }}</td>
        <td>{{ item.code }}</td>
        <td>{{ item.area }}</td>
        <td>
          <span :class="{ success: item.status == '正常', info: item.status == '离线', danger: item.status == '报警' }"> {{ item.status }}</span>
        </td>

        <td><Icon name="map-filling" :size="20" :color="'#2F80ED'"></Icon></td>
      </tr>
    </tbody>
  </table>
</template>

<script lang="ts" setup>
const props = defineProps({
  data: {
    type: Array<any>,
    default: () => [],
  },
});

const datasource = props.data;
</script>
<style lang="scss" scoped>
.table {
  width: 100%;
  font-size: 12px;
  color: #fff;
  border-spacing: 0px 12px;
  .title th {
    border-bottom: 1px solid #ffffff;
    text-align: center;
    padding-bottom: 12px;
  }
  .title th:first-child {
    width: 50px;
  }

  tbody td {
    text-align: center;
    vertical-align: middle;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    padding: 0;
    margin: 0;
  }
  tbody td:first-child {
    background-color: transparent;
  }
  .status {
    background: rgba(255, 255, 255, 0.05);
    margin-right: 4px;
    height: 100%;
    border-left: 4px solid #29ec78;
  }
  .status-icon {
    margin: 8px;
  }
}

.success {
  color: var(--primary-color);
}
.info {
  color: var(--info-color);
}
.danger {
  color: var(--danger-color);
}
</style>
